//
//  XMLBuilder.m
//  XMLBuilder
//
//  Created by shchen on 16/4/5.
//  Copyright © 2016年 shchen. All rights reserved.
//

#import "XMLBuilder.h"
@implementation XMLBuilder
#pragma mark -单例
static XMLBuilder *_instance;
static NSString * Encoding=@"utf-8";
+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [super allocWithZone:zone];
    });
    return _instance;
}

+ (instancetype)sharedInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[self alloc] init];
    });
    return _instance;
}


- (id)copyWithZone:(NSZone *)zone
{
    return _instance;
}
#pragma mark-生成器
+(NSString* )buildByRootXMLElement:(XMLElement *)rootXMLElement{
    //XML头
    return [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"%@\"?>\n%@",Encoding,[rootXMLElement XMLPrint]];
    }
+(BOOL)setEncoding:(NSString *)encoding{
    Encoding=encoding;
    return YES;
}

@end
